package com.cssy.yd.basic.dao.impl;

import com.cssy.yd.basic.dao.BasicFundamentalUnitDAO;
import com.cssy.yd.basic.entity.BasicFundamentalUnitDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-09-28
 */
public class BasicFundamentalUnitDAOImpl extends SqlMapClientDaoSupport implements BasicFundamentalUnitDAO {

    /**
     * 插入数据
     * @param basicFundamentalUnitDO
     * @return 插入数据的主键
     */
    public String insertBasicFundamentalUnitDO(	BasicFundamentalUnitDO basicFundamentalUnitDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("BasicFundamentalUnit.insert", basicFundamentalUnitDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicFundamentalUnitDO
     * @return 查出的记录数
     */
    public Integer countBasicFundamentalUnitDOByExample(BasicFundamentalUnitDO basicFundamentalUnitDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicFundamentalUnit.countByDOExample", basicFundamentalUnitDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicFundamentalUnitDO
     * @return 受影响的行数
     */
    public Integer updateBasicFundamentalUnitDO(BasicFundamentalUnitDO basicFundamentalUnitDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("BasicFundamentalUnit.update", basicFundamentalUnitDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicFundamentalUnitDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicFundamentalUnitDO> findListByExample(BasicFundamentalUnitDO basicFundamentalUnitDO) throws DataAccessException {
        List<BasicFundamentalUnitDO> list = getSqlMapClientTemplate().queryForList("BasicFundamentalUnit.findListByDO", basicFundamentalUnitDO);
        return list;
    }

    /**
     * 根据主键获取basicFundamentalUnitDO
     * @param id
     * @return basicFundamentalUnitDO
     */
    public BasicFundamentalUnitDO findBasicFundamentalUnitDOByPrimaryKey(String id) throws DataAccessException {
    	BasicFundamentalUnitDO basicFundamentalUnitDO = (BasicFundamentalUnitDO) getSqlMapClientTemplate().queryForObject("BasicFundamentalUnit.findByPrimaryKey", id);
        return basicFundamentalUnitDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicFundamentalUnitDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicFundamentalUnit_ex.deleteById", id);
        return rows;
    }

    @Override
   	public List<BasicFundamentalUnitDO> find(SearchConditions scs)
   			throws DataAccessException {
   		List<BasicFundamentalUnitDO> list = getSqlMapClientTemplate().queryForList("BasicFundamentalUnit_ex.find", scs);
   		return list;
   	}

   	@Override
   	public Integer count(SearchConditions scs) throws DataAccessException {
   		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicFundamentalUnit_ex.count", scs);
   		return count;
   	}

}